import request from '@/config/axios'
const API=import.meta.env.VITE_BASES_URL;
import { getAccessToken} from '@/utils/auth'

export interface EarthquakeVO {
  id: number
  eqimId: string
  title: string
  earthquakeMagnitude: number
  earthquakeTime: Date
  longitude: number
  latitude: number
  depth: number
  referenceLocation: string
  area: number
  earthquakeType: number
  isPublish: boolean
  bida: boolean
  phoneConference: boolean
  trigMode: number
  earthquakeId: number
  createTime: Date
  updateTime: Date
}

// 地震列表
export const formalEarthquake = async (dataform) => {
    return await request.post({ url: '/earthquakeData/list', data: dataform })
}

//手动触发
export const saveEarthquake = async (dataform) => {
  return await request.post({ url: '/earthquakeData/create', data: dataform })
}

//删除地震
export const deleteEarthquake = async (type, ids) => {
  return await request.delete({ url: '/earthquakeData/delete/' + type, data: ids })
}

//查询地震信息
export const getEarthquakeById = async (id, type) => {
  return await request.get({ url: '/earthquakeData/' + id + '/' + type})
}

//获取国家地震产品
export const getGJDZCPPT = async (id) => {
  return await request.get({ url: '/earthquakeData/' + id})
}

// 位置名称
export const getNameList = async (lonAndLat) => {
  return await request.get({ url: `/distCity/getCityName?lonAndLat=${lonAndLat}`})
}

// 新增保存地震应急服务信息
export const saveEmergencyServeInfo = async (data) => {
  return await request.post({ url: '/emergencyServeInfo/update', data: data })
}

// 城市列表
export const getCityList = async () => {
  return await request.get({ url: '/distProvince/getProvinceName' })
}

// 在线地图
// 重新生成影响场
export const renewSaveInfluence = async (data) => {
  return request.post(
    {
      url:`${API}/evaluate/influence/renewSaveInfluence`,
      data: data,
      headers: {
        'Authorization':'Bearer ' + getAccessToken(),
      }
    },
  )
}
// 导出影响场
export const exportCurrentEarthInfluence = async (data) => {
  return request.post(
    {
      url:`${API}/evaluate/influence/exportCurrentEarthInfluence`,
      data: data,
      responseType: 'blob',
      headers: {
        'Authorization':'Bearer ' + getAccessToken(),
      }
    },
  )
}
// 地震事件影响场下拉列表
export const currentEarthInfluence = async (params) => {
  return request.get(
    {
      url:`${API}/evaluate/influence/currentEarthInfluence/${params.id}/0/${params.type}`,
      headers: {
        'Authorization':'Bearer ' + getAccessToken(),
      }
    },
  )
}
// 修正详情
export const correctDetail = async (params) => {
  return request.get(
    {
      url:`${API}/evaluate/influence/correctDetail`,
      headers: {
        'Authorization':'Bearer ' + getAccessToken(),
      },
      // params:{earthQuakeId:175,influenceVersion:'2024-10-20 10:59:43'}
      params
    },
  )
}
// 修正
export const correctInfluence = async (data) => {
  return request.post(
    {
      url:`${API}/evaluate/influence/correctInfluence`,
      data: data,
      headers: {
        'Authorization':'Bearer ' + getAccessToken(),
      }
    },
  )
}

// 重新重新生成产品
export const rebuild = async (data) => {
  return request.post(
    {
      url:`${API}/evaluate/rysw/rebuild`,
      data: data,
      headers: {
        'Authorization':'Bearer ' + getAccessToken(),
      }
    },
  )
}
// 导入
export const importInfluence = async (data) => {
  return request.post(
    {
      url:`${API}/evaluate/influence/importInfluence`,
      data: data,
      headers: {
        'Authorization':'Bearer ' + getAccessToken(),
      }
    },
  )
}

// 震区概况
export const getlistData = async (formdata) => {
  console.log(formdata);
  return await request.get({ url: `/over/view/overView?shockId=${formdata.id}&typeId=${formdata.tabData}&divisionCode=${formdata.divisionCode}` })
}

// 辅助决策
export const getassistantListData = async (formdata) => {
  return await request.get({
    url: `/assist/decision/get?eqId=${formdata.id}&earthquakeType=${formdata.tabData}&divisionCode=${formdata.divisionCode}&version=${formdata.version}` })
}

// 根据登录用户归属省份获取省驻地经纬度坐标信息
export const getDefaultCoordinates = async () => {
  return request.get({ url: `/earthquakeData/getGovernment`})
}
